﻿package mortal.game.view.platform.platformTencent
{
    import Message.DB.Tables.*;
    import __AS3__.vec.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.platform.*;
    import mortal.game.view.yyZiZuan.*;
    import mortal.mvc.core.*;

    public class PlatformQQDailyPanel extends PlatformTencentBasePanel
    {
        private var _dailyVipLevelGiftList:GTileList;
        private var _oneKeyGetBtn:GLoadingButton;
        private var _yearDailyGift:GTileList;
        private var _deluxeDailyGift:GTileList;

        public function PlatformQQDailyPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._dailyVipLevelGiftList = UIFactory.tileList(24, 60, 516, 341, this, "TileListQQYellowStyle");
            this._dailyVipLevelGiftList.columnWidth = 247;
            this._dailyVipLevelGiftList.rowHeight = 64;
            this._dailyVipLevelGiftList.horizontalGap = 4;
            this._dailyVipLevelGiftList.verticalGap = 3;
            this._dailyVipLevelGiftList.setStyle("cellRenderer", PlatformQQDailyCellRender);
            this._dailyVipLevelGiftList.direction = GBoxDirection.VERTICAL;
            this._yearDailyGift = UIFactory.tileList(324 + 145 - 15, 30 + 507 - 193, 500, 80, this);
            this._yearDailyGift.columnWidth = 43;
            this._yearDailyGift.rowHeight = 40;
            this._yearDailyGift.setStyle("cellRenderer", YYZiZuanGiftCellRender);
            this._yearDailyGift.direction = GBoxDirection.HORIZONTAL;
            return;
        }// end function

        override protected function createYellow() : void
        {
            super.createYellow();
            _bg.imgUrl = ImagesConst.QQYeallowVipNewBg3;
            this._oneKeyGetBtn = UIFactory.gLoadingButton(ResFileConst.QQYellowOneKeyGetBtn, 300 + 230 - 120, 500 + 43 - 80 - 50, 88, 29, this);
            this._oneKeyGetBtn.configEventListener(MouseEvent.CLICK, this.onClickHandle);
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.QQYellowDescTxt, 200 - 58, 10 + 9 + 5, this));
            var _loc_1:int = 0;
            while (_loc_1 < 10)
            {
                
                pushUIToDisposeVec(UIFactory.bg(24 + _loc_1 % 2 * 251, 60 + int(_loc_1 / 2) * 67, 247, 64, this, ImagesConst.QQYellowBlockBg));
                _loc_1++;
            }
            var _loc_2:* = UIFactory.gTextField("年费黄钻贵族额外奖励", 100 + 60 - 130, 100 + 251, 300, 40, this, GlobalStyle.textFormatAnHuan.setBold(true).setSize(16));
            _loc_2.mouseEnabled = false;
            pushUIToDisposeVec(_loc_2);
            _xufeiBtn.x = 20 + 100 + 27 - 70;
            _xufeiYearBtn.x = 20 + 200 + 73 - 70;
            return;
        }// end function

        override protected function createBlue() : void
        {
            super.createBlue();
            _bg.imgUrl = ImagesConst.QQBlueVipNew3;
            this._oneKeyGetBtn = UIFactory.gLoadingButton(ResFileConst.QQBlueOneKeyGetBtn, 300 + 230 - 120 + 16, 500 + 56 - 80 - 57 - 7, 87, 31, this);
            this._oneKeyGetBtn.configEventListener(MouseEvent.CLICK, this.onClickHandle);
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.QQBlueDescTxt, 200 - 58, 10 + 9 + 5, this));
            var _loc_1:int = 0;
            while (_loc_1 < 10)
            {
                
                pushUIToDisposeVec(UIFactory.bg(24 + _loc_1 % 2 * 251, 60 + int(_loc_1 / 2) * 67, 247, 64, this, ImagesConst.QQBlueBlockBg));
                _loc_1++;
            }
            var _loc_2:* = UIFactory.gTextField("年费蓝钻贵族额外奖励", 100 + 60 - 130, 100 + 251, 300, 40, this, GlobalStyle.textFormatAnHuan.setBold(true).setSize(16));
            _loc_2.mouseEnabled = false;
            var _loc_3:* = UIFactory.gTextField("豪华蓝钻贵族额外奖励", 400 + 108 - 243 + 17, 100 + 251, 300, 40, this, GlobalStyle.textFormatAnHuan.setBold(true).setSize(16));
            _loc_3.mouseEnabled = false;
            pushUIToDisposeVec(_loc_2);
            pushUIToDisposeVec(_loc_3);
            this._deluxeDailyGift = UIFactory.tileList(324 + 145 - 15, 30 + 507 - 193, 500, 80, this);
            this._deluxeDailyGift.columnWidth = 43;
            this._deluxeDailyGift.rowHeight = 40;
            this._deluxeDailyGift.setStyle("cellRenderer", YYZiZuanGiftCellRender);
            this._deluxeDailyGift.direction = GBoxDirection.HORIZONTAL;
            _xufeiBtn.x = 20 + 100 - 70;
            _xufeiYearBtn.x = 20 + 200 + 53 - 70;
            return;
        }// end function

        private function onClickHandle(event:MouseEvent) : void
        {
            var _loc_2:Vector.<TPlatformGift> = null;
            var _loc_3:int = 0;
            var _loc_4:TPlatformGift = null;
            if (event.target == this._oneKeyGetBtn)
            {
                _loc_2 = PlatformGiftConfig.instance.vipGiftVec;
                _loc_3 = 0;
                while (_loc_3 < _loc_2.length)
                {
                    
                    if (PlatformVIPGiftsUtil.getReceiveTypeByTPlatformGift(_loc_2[_loc_3], false) == PlatformVIPGiftGroup.CanReceive)
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PlatformRequestQQYellowGift, PlatformGiftConfig.instance.vipGiftVec[_loc_3].id));
                    }
                    _loc_3++;
                }
                if (PlatformTencentUtil.hasDailyLoginGiftReward())
                {
                    _loc_4 = PlatformGiftConfig.instance.dailyLoginGift;
                    if (_loc_4)
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PlatformRequestQQYellowGift, _loc_4.id));
                    }
                }
                if (PlatformTencentUtil.hasDailyDeluxeGiftReward())
                {
                    _loc_4 = PlatformGiftConfig.instance.dailyDeluxeGift;
                    if (_loc_4)
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PlatformRequestQQYellowGift, _loc_4.id));
                    }
                }
            }
            return;
        }// end function

        override public function refresh() : void
        {
            var _loc_1:int = 0;
            var _loc_2:* = new DataProvider();
            _loc_1 = 0;
            while (_loc_1 < PlatformGiftConfig.instance.vipGiftVec.length)
            {
                
                _loc_2.addItem(PlatformGiftConfig.instance.vipGiftVec[_loc_1]);
                _loc_1++;
            }
            this._dailyVipLevelGiftList.dataProvider = _loc_2;
            this._dailyVipLevelGiftList.drawNow();
            this._yearDailyGift.dataProvider = this.getGiftListDataProviderByCode(PlatformGiftConfig.instance.dailyLoginGift.reward);
            this._yearDailyGift.x = 324 - 100 + 14 - 0.5 * (this._yearDailyGift.dataProvider.length * 43);
            this._yearDailyGift.drawNow();
            if (this._deluxeDailyGift)
            {
                this._deluxeDailyGift.dataProvider = this.getGiftListDataProviderByCode(PlatformGiftConfig.instance.dailyDeluxeGift.reward);
                this._deluxeDailyGift.x = 324 - 100 + 14 + 250 - 0.5 * (this._deluxeDailyGift.dataProvider.length * 43);
                this._deluxeDailyGift.drawNow();
            }
            if (PlatformTencentUtil.hasDailyVipReward() || PlatformTencentUtil.hasDailyLoginGiftReward() || PlatformTencentUtil.hasDailyDeluxeGiftReward())
            {
                if (this._oneKeyGetBtn)
                {
                    setBtnCanGetStyle(this._oneKeyGetBtn);
                }
            }
            else if (this._oneKeyGetBtn)
            {
                setBtnCanNotGetStyle(this._oneKeyGetBtn);
            }
            return;
        }// end function

        private function getGiftListDataProviderByCode(param1:int) : DataProvider
        {
            var _loc_5:Array = null;
            var _loc_6:ItemData = null;
            var _loc_9:YYZiZuanGiftDataGroup = null;
            var _loc_2:* = new DataProvider();
            var _loc_3:* = new ItemData(param1).itemInfo as ItemGiftBagInfo;
            var _loc_4:* = _loc_3.itemList1.split("&");
            var _loc_7:* = _loc_4.length;
            var _loc_8:int = 0;
            while (_loc_8 < _loc_4.length)
            {
                
                _loc_5 = _loc_4[_loc_8].split("#");
                _loc_6 = new ItemData(int(_loc_5[1]));
                _loc_9 = new YYZiZuanGiftDataGroup();
                _loc_9.itemCode = int(_loc_5[1]);
                _loc_9.itemAmount = _loc_5[2];
                _loc_9.isBind = true;
                _loc_2.addItem(_loc_9);
                _loc_8++;
            }
            return _loc_2;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            if (this._deluxeDailyGift)
            {
                this._deluxeDailyGift.dispose(param1);
                this._deluxeDailyGift = null;
            }
            if (this._dailyVipLevelGiftList)
            {
                this._dailyVipLevelGiftList.dispose(param1);
                this._dailyVipLevelGiftList = null;
            }
            if (this._oneKeyGetBtn)
            {
                this._oneKeyGetBtn.dispose(param1);
                this._oneKeyGetBtn = null;
            }
            if (this._yearDailyGift)
            {
                this._yearDailyGift.dispose(param1);
                this._yearDailyGift = null;
            }
            super.disposeImpl(param1);
            return;
        }// end function

    }
}
